import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        user: {},
        collect: [],
        ident: '', // 验证码
        nav: -1
    },
    mutations: {
        set_nav(state, payload) {
            state.nav = payload
        },
        saveUser(state, payload) {
            state.user = payload;
        },
        setCollect(state, collect) {
            state.collect = collect
        },
        // 保存当前验证码
        setIdent(state, payload) {
            state.ident = payload
        },
        // 清除所有state
        clearAllState(state) {
            Object.keys(state).forEach(item => {
                Vue.delete(state, item)
            })
        },
    },
    getters: {

    },
    actions: {},
    modules: {}
})